<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MVCWeb.Models.ViewData.DocumentNewViewData>" %>
<%@ Import Namespace="MVCWeb.Helpers" %>
<%@ Register Src="~/Views/Menu/MainMenu.ascx" TagName="MainMenu" TagPrefix="mmuc" %>

<%@ Register Src="~/Views/Shared/LogOnUserControl.ascx" TagName="LogOnUserControl" TagPrefix="louc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Create document</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">    
    <script type="text/javascript">
        $(document).ready(function() {
            $("#DocumentForm").validate({
                rules: {
                    Name: {
                        required: true
                    },
                    FullPath: {
                        required: true
                    }
                   
                },
                messages: {
                    Name: {
                        required: "Name cannot be blank"
                    },
                    FullPath: {
                        required: "File cannot be blank"
                    }                    
                }
            });
            
            
            $("#save_new").click(function() {
                $("#IsSaveNew").val("true");
            });


        });
    </script>
    <louc:LogOnUserControl ID="LogOnUserControl1" runat="server" />
    <!-- BEGIN: MainMenu -->
    <mmuc:MainMenu ID="MainMenu1" runat="server" />
    <!-- END: MainMenu -->
    <br />
    <br />
    <%= Html.ValidationSummary()%>
    <% using (Html.BeginForm("Create", "Doc", FormMethod.Post, new { id = "DocumentForm", enctype = "multipart/form-data" }))
       {%>
    <fieldset>
        <legend>Create document</legend>
        <p>
            <label for="Name">
                Name:</label>
            <%= Html.TextBox("Name", "")%>
            <%= Html.ValidationMessage("Name", "*")%>
        </p>
        <p>
            <label for="Desc">
                Description:</label>
            <%= Html.TextArea("Desc")%>
            <%= Html.ValidationMessage("Desc", "*")%>
        </p>
        <p>
            <label for="FullPath">
                File:</label>
            <input type="file" name="FullPath" id="FullPath" size="34"/>
            <%= Html.ValidationMessage("FullPath", "*")%>
        </p>
        <p>
            <label for="DocParentCategoryId">
                Choose a category:</label>
            <%= Html.DropDownList("DocParentCategoryId", new SelectList(ViewData.Model.Categories, "DocCategoryId", "Category"))%>
        </p>
        <p>
            <label for="DocCategoryId">
                Choose a sub category:</label>
            <%= Html.CascadingDropDownListJQuery("DocCategoryId", "DocParentCategoryId")%>
        </p>
        <%= Html.Hidden("CommunityId", ViewData["CommunityId"].ToString()) %>        
        <%= Html.Hidden("IsSaveNew")%>
        <%--<p>
            <label for="CommunityId">
                Community:</label>
              
            <% if (!String.IsNullOrEmpty(ViewData["CommunityId"].ToString())){ %>  
                <%= Html.DropDownList("CommunityId", new SelectList(ViewData.Model.Communities, "CommunityId", "Name", ViewData["CommunityId"]),new {disabled = "disabled"})%>
            <% }else %>
                <%= Html.DropDownList("CommunityId", new SelectList(ViewData.Model.Communities, "CommunityId", "Name"))%>
            <%= Html.ValidationMessage("CommunityId", "*")%>
        </p>--%>
        <br />
        <p>
            <input id="save_new" name="save_new" type="submit" value="Save & New" />
            <input id="save_view" name="save_view" type="submit" value="Save & View" />            
            <input type="reset" value="Reset" />
        </p>
    </fieldset>
    <% } %>
    <div>
        <%=Html.ActionLink("Go back", "Index", "Community") %>
    </div>
</asp:Content>
